package com.china08.yxyapi.api.manage.stu.mystudy.tifenbao.exercise;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.tifenbao.TifenbaoExerciseJudgeService;

/**
 * 计划解答试题判断
 *
 */
@RestController
public class TifenbaoExerciseJudgeController {

    @Autowired
    private TifenbaoExerciseJudgeService tifenbaoExerciseJudgeService;

    @RequestMapping(value = "/api_yw/manage/stu/mystudy/tifenbao/exercise/judge", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
        RespModel model = tifenbaoExerciseJudgeService.judge(reqModel.pkId, reqModel.quesId, reqModel.answer,
                reqModel.result, reqModel.time);
        return model;
    }

    /**
     * 请求参数
     * 
     */
    protected static class ReqModel extends YxyApiReqModel {
        // 知识点计划id
        public String pkId;
        // 试题id
        public String quesId;
        // 输入答案
        public String answer;
        // (主观题) 结果
        public boolean result;
        // 用时
        public String time;
    }

    /**
     * 响应参数
     * 
     */
    public static class RespModel extends YxyApiRespModel {
        // 计划知识点id
        public String pkId;
        // 知识点名称
        public String knowName;
        // 试题记录id
        public String trainQuesId;
        // 已闯关数
        public Integer passTask;
        // 总关数
        public Integer task;
        // 1闯关完成2继续练习0连续错两道题
        public Integer status;
        // 试题body
        public Object questionBody;
        // 我的答案
        public String answerOfMy;
        // 是否正确 0、错误 1、正确
        public Integer passed;
        // 用时
        public String time;
    }
}
